package org.agile2soft.nexoma.tapestry.encoder;

import org.agile2soft.nexoma.controller.UserController;
import org.agile2soft.nexoma.entity.User;
import org.apache.tapestry5.EventContext;
import org.apache.tapestry5.ValueEncoder;
import org.hibernate.SessionFactory;

import br.com.arsmachina.module.service.PrimaryKeyTypeService;
import br.com.arsmachina.tapestrycrud.encoder.Encoder;
import br.com.arsmachina.tapestrycrud.hibernate.encoder.HibernatePrimaryKeyEncoder;

public class UserEncoder
       extends HibernatePrimaryKeyEncoder<User, String>
       implements Encoder<User,String> {

//    public UserEncoder(Class<User> entityClass,
//            UserController controller,
//            SessionFactory sessionFactory,
//            PrimaryKeyTypeService primaryKeyTypeService) {
//        super(entityClass, controller, sessionFactory, primaryKeyTypeService);
//    }
    public UserEncoder(Class<User> entityClass,
            UserController controller,
            SessionFactory sessionFactory) {
        super(entityClass, controller, sessionFactory);
    }
    public String toClient(User value) {
        return value.getDocumentNumber();
    }

    public ValueEncoder<User> create(Class<User> type) {
        return this;
    }

    public Object toActivationContext(User object) {
        return object.getName();
    }

    public User toObject(EventContext value) {
        return null;
    }

    public String toLabel(User object) {
        return null;
    }

}
